import axios from "@/api/config"
// init：初始化管理 开始=======
//独立机构 开始
export const independent = {
    list: async () => { //获取独立机构列表树数据
        const url = '/ssm/root/unit/list';
        let res = await axios.get(url);
        return res;
    },
    detail: async (data) => { //获取独立机构详情
        const url = '/ssm/root/unit/'+data;
        let res = await axios.get(url);
        return res;
    },
    update: data=>axios.put('/ssm/root/unit/update',data),  //获取独立机构编辑
    add: data=>axios.post('/ssm/root/unit/add',data),  //获取独立机构新增
    delete: async (data) => { //独立机构删除
        const url = '/ssm/root/unit/delete/'+data;
        let res = await axios.delete(url);
        return res;
    }
}
//菜单管理 开始
export const menu = {
    list: data=>axios.post('/ssm/menu/list',data),  //列表
    delete: async (data) => { //删除菜单
        const url = '/ssm/menu/delete/'+data;
        let res = await axios.delete(url);
        return res;
    },
    detail: async (data) => { //详情
        const url = '/ssm/menu/'+data;
        let res = await axios.get(url);
        return res;
    },
    update: data=>axios.put('/ssm/menu/update',data),  //编辑
    add: data=>axios.post('/ssm/menu/add',data),  //新增
}
//菜单 数据规则
export const rule = {
    list: data=>axios.post('/ssm/data/rule/page',data),
    delete: async (data) => {
        const url = '/ssm/data/rule/delete/'+data;
        let res = await axios.delete(url);
        return res;
    },
    detail: async (data) => {
        const url = '/ssm/data/rule/'+data;
        let res = await axios.get(url);
        return res;
    },
    update: data=>axios.put('/ssm/data/rule/update',data),
    add: data=>axios.post('/ssm/data/rule/add',data),
}

//菜单管理结束
//管理员管理开始
export const admin = {
    list: data=>axios.post('/ssm/admin/user/page',data),
    delete: async (data) => {
        const url = '/ssm/admin/user/delete/'+data;
        let res = await axios.delete(url);
        return res;
    },
    detail: async (data) => {
        const url = '/ssm/admin/user/'+data;
        let res = await axios.get(url);
        return res;
    },
    update: data=>axios.put('/ssm/admin/user/update',data),
    reset: async (data) => {//重置密码
        const url = '/ssm/admin/user/password/reset/'+data;
        let res = await axios.put(url);
        return res;
    },
    enable: async (data) => {//启用
        const url = '/ssm/admin/user/enable/'+data;
        let res = await axios.put(url);
        return res;
    },
    disable: async (data) => {//禁用
        const url = '/ssm/admin/user/disable/'+data;
        let res = await axios.put(
            url);
        return res;
    },
    add: data=>axios.post('/ssm/admin/user/add',data)
}
//管理员管理结束
//字典分组开始
export const group = {
    list: data=>axios.post('/ssm/param/group/page',data),
    delete: async (data) => {
        const url = '/ssm/param/group/delete/'+data;
        let res = await axios.delete(url);
        return res;
    },
    detail: async (data) => {
        const url = '/ssm/param/group/'+data;
        let res = await axios.get(url);
        return res;
    },
    update: data=>axios.put('/ssm/param/group/update',data),
    add: data=>axios.post('/ssm/param/group/add',data),
}

//字典分组结束

// 通用数据字典开始
export const general = {
    list: data=>axios.post('/ssm/root/param/page',data),
    delete: async (data) => {
        const url = '/ssm/root/param/delete/'+data;
        let res = await axios.delete(url);
        return res;
    },
    detail: async (data) => {
        const url = '/ssm/root/param/'+data;
        let res = await axios.get(url);
        return res;
    },
    update: data=>axios.put('/ssm/root/param/update',data),
    add: data=>axios.post('/ssm/root/param/add',data),
    getGroups: async () => {//获取公共参数 所属分组
        const url = '/ssm/param/group/public/list';
        let res = await axios.get(url);
        return res;
    },
    updateState: async (data) => {
        const url = '/ssm/root/param/'+data.id+'/'+data.state;
        // let res = await axios.put(url,'',{headers:{'Content-Type':'application/x-www-form-urlencoded'}});
        let res = await axios.put(url);
        return res;
    }
}
// 通用数据字典结束

// init：初始化管理 结束=======

// system：系统管理 开始=======
//导航管理 开始
export const navigation = {
    list: data=>axios.post('/ssm/navigation/page',data),
    delete: async (data) => {
        const url = '/ssm/navigation/delete/'+data;
        let res = await axios.delete(url);
        return res;
    },
    detail: async (data) => {
        const url = '/ssm/navigation/'+data;
        let res = await axios.get(url);
        return res;
    },
    update: data=>axios.put('/ssm/navigation/update',data),
    add: data=>axios.post('/ssm/navigation/add',data)
}
//导航管理 结束
//数字字典 开始
export const dictionary = {
    list: data=>axios.post('/ssm/param/page',data),
    delete: async (data) => {
        const url = '/ssm/param/delete/'+data;
        let res = await axios.delete(url);
        return res;
    },
    detail: async (data) => {
        const url = '/ssm/param/'+data;
        let res = await axios.get(url);
        return res;
    },
    update: data=>axios.put('/ssm/param/update',data),
    add: data=>axios.post('/ssm/param/add',data),
    getGroups: async () => {//获取业务参数 所属分组
        const url = '/ssm/param/group/business/list';
        let res = await axios.get(url);
        return res;
    },
    updateState: async (data) => {
        const url = '/ssm/param/'+data.id+'/'+data.state;
        let res = await axios.put(url);
        return res;
    }
}
//数字字典 结束
// system：系统管理 结束=======

// system：密级管理 开始=======
export const classified = {
    list: data=>axios.post('/ssm/user/classified/page',data),
    updateClassified: async (data) => {
        const url = '/ssm/user/'+data.id+'/'+data.classified;
        let res = await axios.put(url);
        return res;
    }
}
// system：密级管理 结束=======